// ex7_13_3.cpp
#include <iostream>

struct box
{
	char maker[40];
	float height;
	float width;
	float length;
	float volume;
};

void display(struct box[] , int n);
void display_address(struct box *b, int n);
int main(void)
{
	using namespace std;
	box boxs[] = 
	{
		{"s1", 5.0, 3.0, 4.0, 60.0},
		{"s2", 10.0, 6.0, 8.0, 480.0}
	};
	int n = sizeof boxs / sizeof boxs[0];
	cout << "length of boxs is: " << n << endl;
	cout << "display function: \n";
	display(boxs, n);
	cout << "display_address function: \n";
	display_address(boxs, n);
}

void display(struct box b1[], int n)
{
	using namespace std;
	for (int i = 0; i < n; i++)
	{
		b1[i].volume = b1[i].height * b1[i].width * b1[i].length;

		cout << b1[i].maker << " " << b1[i].height << " "
			 << b1[i].width << " " << b1[i].length << " "
			 << b1[i].volume << endl;
	}
}

void display_address(struct box *b, int n)
{
	using namespace std;
	for (int i = 0; i < n; i++)
	{
		b[i].volume = b[i].height * b[i].width * b[i].length;
		cout << b[i].maker << " " << b[i].height << " "
			 << b[i].width << " " << b[i].length << " "
			 << b[i].volume << endl;	
	}
}
